package entity

import (
	"time"

	"gorm.io/gorm"
	"shqsoft.cn/pas3ui/base"
)

//CompAcco 对公存款认定
type CompAcco struct {
	ACID   int        `gorm:"AUTO_INCREMENT;primary_key;column:ACID"`
	ACNO   string     `gorm:"column:ACNO;"`
	BANO   string     `gorm:"column:BANO"`
	UTNM   string     `gorm:"column:UTNM;"`
	UTID   int        `gorm:"column:UTID;"`
	CYNM   string     `gorm:"column:CYNM;"`
	ITNM   string     `gorm:"column:ITNM;"`
	CUNM   string     `gorm:"column:CUNM"`
	OPDT   *time.Time `gorm:"column:OPDT;type:date;"`
	VLDT   *time.Time `gorm:"column:VLDT;type:date;"`
	MADT   *time.Time `gorm:"column:MADT;type:date;"`
	RDNM   string     `gorm:"column:RDNM;"`
	INRT   *float64   `gorm:"column:INRT;"`
	CLDT   *time.Time `gorm:"column:CLDT;type:date;"`
	ACBL   *float64   `gorm:"column:ACBL;"`
	PRBL   *float64   `gorm:"column:PRBL"`
	PERD   string     `gorm:"column:PERD;"`
	ISDIVI bool       `gorm:"column:ISDIVI;"`
	FPNO   *int       `gorm:"column:FPNO"`
	FPNM   string     `gorm:"column:FPNM;"`
}

//TableName 对公账户表名
func (CompAcco) TableName() string {
	return "V_COMP_ACCO"
}

// AfterFind 查询后触发器
func (i *CompAcco) AfterFind(tx *gorm.DB) (err error) {
	i.ACNO = base.CdnoTM(i.ACNO)
	i.BANO = base.AcnoTM(i.BANO)
	return
}

func CompAccoEF() base.EntityFunc {
	return func() interface{} {
		entity := CompAcco{}
		return &entity
	}
}
func CompAccoESF() base.EntitiesFunc {
	return func() interface{} {
		var entities []CompAcco
		return &entities
	}
}

func init() {
	dao := base.NewDefaultDao(CompAccoEF(), CompAccoESF(), nil, "ch")
	filter := base.DefaultFilter{
		FilterColName: "UTID",
	}
	dao.Fileter = &filter
	dao.Fileter.SetDB("ch")
	base.DaoPoolObj.Put("CompAcco", dao)
}
